package com.android;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class BasicActivity extends Activity {

	protected static Context mContext;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

	}
    
    protected boolean isOnline() {
    	boolean connected = false;
		ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
		try {
			connected = cm.getActiveNetworkInfo().isConnectedOrConnecting();
		} catch (Exception e) {
			Log.e("error", "Erro: " + e.getMessage());
		}
		return connected;
	}
    
    protected void noConnectionAlert(String message) {
		Builder alertBuilder = new AlertDialog.Builder(BasicActivity.this);
		alertBuilder.setMessage(message)
			.setNeutralButton("OK", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int id) {
					dialog.dismiss();								
				}
			});
		
		AlertDialog alert = alertBuilder.create();
		alert.show();
    }

    protected void setFont(int id) {
        TextView txt = (TextView) findViewById(id);
        Typeface font = Typeface.createFromAsset(getAssets(), "ACUTATR_.TTF");  
        txt.setTypeface(font);
    }
    
}
